//
//  JMBasicViewController.m
//  JMDome_1
//
//  Created by ios on 15/6/11.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMBasicViewController.h"

@interface JMBasicViewController ()

@end

@implementation JMBasicViewController

/**
    初始化一些数据
 */
- (UIColor *)backGroundColor
{
    if (!_backGroundColor) {
        _backGroundColor = UIColorFromRGB(0xf3f3f3);
    }
    return _backGroundColor;
}


- (UIButton *)backBtn
{
    if (!_backBtn) {
        UIButton *button = [[UIButton alloc]init];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"projectImage.bundle/main_back_image2"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(10, 20, 40, 40);
        _backBtn = button;
    }
    return _backBtn;
}

-(void)backBtnClick:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    [self.view addSubview:self.backBtn];
     self.navBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.navBackBtn.frame = CGRectMake(0, 0, 40, 40);
    [self.navBackBtn setImage:[UIImage imageNamed:@"projectImage.bundle/maiv_back_image"] forState:UIControlStateNormal];
    [self.navBackBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:self.navBackBtn];
    self.navigationItem.leftBarButtonItem = backItem;
}
-(void)doBack:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = self.backGroundColor;


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)dealloc{
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
